package main

import (
	"go_service/database/mysql"
	"go_service/database/redis"
	"os"

	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
)

func main() {
	InitConfig()
	r := gin.Default()
	mysql.Init()
	redis.Init()
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	r.Run(viper.GetString("server.port"))
}

func InitConfig() {
	wd, _ := os.Getwd()
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(wd)
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
}
